package com.lry.consumer.consumer;

import com.lry.interfac.Common;
import com.lry.interfac.Test;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.Method;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author JiangJie
 * @create 2020-12-02 11:58
 */
@RestController
@RequestMapping("/")
public class TestController {

    @DubboReference(loadbalance = "ip")
    private Test test;
    //cluster = "broadcast"没办法获取所有提供者的返回结果
    //可以采取分组聚合的方式，自己扩展Merger实现这个
    @DubboReference(cluster = "broadcast",group = "*",merger = "string")
    private Common common;

    @RequestMapping("/test/{ttuNum}")
    public String test(@PathVariable String ttuNum){
        return test.sayHello(ttuNum);
    }

    @RequestMapping("/common")
    public void test(){
        System.out.println(common.common());
    }
}
